package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.iview.CarCheckView
import hlhj.fhp.checkpoint.javaBean.AddYearBean
import hlhj.fhp.checkpoint.javaBean.MyBaseBean
import hlhj.fhp.checkpoint.javaBean.YearLimitBean

/**
 * Created by Never Fear   on 2018\11\8 0008.
Never More....
 */
class CarCheckModule :BaseModule {
    var listener:CarCheckView?=null

    fun getYearLoc(c:Context){
        Apis?.getYearLimit()
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<YearLimitBean>>(c){
                                override fun httpSuccess(t: Response<YearLimitBean>) {
                                    listener?.getYearLoc(t.body())
                                }
                            })
                }
    }

    fun add(plate_number:String,vin:String,engine_number:String,examine_date:String,owner_name:String,original_price:String,c:Context){
        Apis.addYear(plate_number, vin, engine_number, examine_date, owner_name, original_price)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<AddYearBean>>(c){
                                override fun httpSuccess(t: Response<AddYearBean>) {
                                    listener?.addYearResp(t.body())
                                }
                            })
                }
    }



}